/**
 * 模型
 */
var mongoose = require('mongoose');
var ObjectId = mongoose.Schema.Types.ObjectId;
module.exports={
    user:{//用户
        username:String,
        password:String,
        email:String,
        avatar:String,
        addTime:{type:Date,default:Date.now},
        is_online:{type:Number,default:0}//是否在线,0:不在线 1:在线
    },
    article:{//文章
        title:String,
        content:String,
        intro:String,
        pic:{type:String,default:''},
        pv:{type:Number,default:0},
        user_id: { type:ObjectId, ref: 'user' },
        cat_id: { type:ObjectId, ref: 'category' },
        cat_name: { type:String},
        addtime:{type:Date,default:Date.now},
        comments:[{user:{type:ObjectId, ref: 'user'},content:{type:String,default:'',require:true},addtime:{type:Date,default:Date.now}}],
        is_md:{type:String,require:true,default:''}
    },
    category:{//文章分类
        cat_name:{type:String,default:'',require:true},
        art_num:{type:Number,default:0}
    }
};

